const baseURL = process.env.NODE_ENV === 'production' ? '/html/page' : '/'

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  app: {
    baseURL: baseURL,
    head: {
      htmlAttrs: { lang: 'zh-CN', amp: true },
      meta: [
        { charset: 'utf-8' },
        { name: 'viewport', content: 'width=device-width, initial-scale=1, viewport-fit=cover' },
        { name: 'format-detection', content: 'telephone=no,email=no' },
        { name: 'robots', content: 'index,follow' },
        // { 'http-equiv': 'Content-Security-Policy', content: 'upgrade-insecure-requests' }
      ],
      link: [
        {
          rel: 'preconnect',
          href: '//static.pjpiao.com',
          crossorigin: true
        }
      ],
      script: [
        { src: '//polyfill.alicdn.com/v3/polyfill.js?features=es5,es6,es7&flags=gated' }
      ]
    }
  },
  build: {
    transpile: ['watth5-ui', '@wattjs/peach', '@wattjs/network'],
  },
  loadingIndicator: '@/skeleton.h5.html', // html文件 骨架适合h5
  components: [
    {
      path: '~/components',
      pathPrefix: false
    }
  ],
  css: ['assets/styl/index.less'],
  devtools: { enabled: true },
  devServer: {
    host: 'test.jsvue.cn',
    https: true,
    port: 443
  },
  modules: ['@vant/nuxt', '@pinia/nuxt'],
  webpack: {
    extractCSS: { allChunks: true }
  },
  vant: {
    importStyle: true,
    lazyload: {
      lazyComponent: true
    },
  },
  postcss: {
    plugins: {
      'postcss-px-to-viewport-8-plugin': {
        exclude: [], // ex: /.*pc.css$/
        propList: ['', '!font*'],
        landscape: true,
        viewportWidth: 375 // 设计稿的宽度 vant UI be 375
      }
    }
  },
  runtimeConfig: {
    public: {},
    app: {
      'BASE_URL': 'https://api.jsvue.cn',
      'XSRF_HEADER': 'x-basement-token',
      'BUS_TYPE': 7, // 上传业务枚举
      'APP_ID': 'H5D9B674D',
      'APP_NAME': '代码演示库',
    }
  },
  plugins: [
    { src: '~/plugins/watt-ui', ssr: false },
    { src: '~/plugins/mitt'}
  ]
})
